package com.ruoyi.common.core.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

public class RandomUtils {
    public static String generateByTimestamp() {
        // 获取当前时间戳
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String timestamp = sdf.format(new Date());
        // 生成 4 位随机数
        Random random = new Random();
        int randomNum = random.nextInt(9000) + 1000;
        // 组合时间戳和随机数作为订单号
        return timestamp + randomNum;
    }
}
